
clear all

local path0="C:\Dropbox\GeneticsProject (1)\REStat\round_accepted_replication_files\"
local path1="C:\Dropbox\GeneticsProject (1)\REStat\round_accepted_replication_files\outregs"

capture cd "`path0'Workfiles"
set more off
use completed_data, clear


	* create settler mortality with the African data corrected based on Albouy
	capture drop logmort3
	gen logmort3=logmort2
	replace logmort3=logmort if countrycode=="SGP" | countrycode=="AUS"
	
	gen lnUKdist=log(geo_UK_distw)

		
	
	*** OLS
	reg pwt_ln_rgdpwok idv if cont==1, robust 
	outreg2 idv using "`path1'\RR_table003.txt" , ///
		replace bdec(3) rdec(3) aster nocons nolabel ctitle("OLS: Asia") 
		
	reg pwt_ln_rgdpwok idv if cont==2, robust 
	outreg2 idv using "`path1'\RR_table003.txt" , ///
		append bdec(3) rdec(3) aster nocons nolabel ctitle("OLS: Europe") 
		
	reg pwt_ln_rgdpwok idv if cont==3, robust 
	outreg2 idv using "`path1'\RR_table003.txt" , ///
		append bdec(3) rdec(3) aster nocons nolabel ctitle("OLS: Africa") 
		
	reg pwt_ln_rgdpwok idv if cont==4, robust 
	outreg2 idv using "`path1'\RR_table003.txt" , ///
		append bdec(3) rdec(3) aster nocons nolabel ctitle("OLS: America") 
	
	xi: reg pwt_ln_rgdpwok idv i.cont if cont==1 | cont==2 | cont==3, robust 
	outreg2 idv using "`path1'\RR_table003.txt" , ///
		append bdec(3) rdec(3) aster nocons nolabel ctitle("OLS: Africa + Asia + Europe") 
		
	xi: reg pwt_ln_rgdpwok idv i.cont if cont==1 |  cont==3, robust 
	outreg2 idv using "`path1'\RR_table003.txt" , ///
		append bdec(3) rdec(3) aster nocons nolabel ctitle("OLS: Africa + Asia ") 
		
	xi: reg pwt_ln_rgdpwok idv i.cont  if oecd==1, robust 
	outreg2 idv using "`path1'\RR_table003.txt" , ///
		append bdec(3) rdec(3) aster nocons nolabel ctitle("OLS: OECD") 
	
	xi: reg pwt_ln_rgdpwok idv i.cont if oecd==0, robust 
	outreg2 idv using "`path1'\RR_table003.txt" , ///
		append bdec(3) rdec(3) aster nocons nolabel ctitle("OLS: non-OECD") 
		
	*** IV	
	ivreg2 pwt_ln_rgdpwok (idv = distM_UK) if cont==1, robust ffirst
	matrix A=e(first)
	local R2first=A[2,1]
	local Ffirst =A[3,1]
	outreg2 idv using "`path1'\RR_table003.txt" , ///
		append bdec(3) rdec(3) aster nocons nolabel ctitle("IV: Asia") ///
		addstat("1st stage F-stat", `Ffirst',"Partial R2",`R2first')
		
		
	ivreg2 pwt_ln_rgdpwok (idv = distM_UK) if cont==2, robust ffirst
	matrix A=e(first)
	local R2first=A[2,1]
	local Ffirst =A[3,1]
	outreg2 idv using "`path1'\RR_table003.txt" , ///
		append bdec(3) rdec(3) aster nocons nolabel ctitle("IV: Europe") ///
		addstat("1st stage F-stat", `Ffirst',"Partial R2",`R2first')
		
		
	ivreg2 pwt_ln_rgdpwok (idv = distM_UK) if cont==3, robust ffirst
	matrix A=e(first)
	local R2first=A[2,1]
	local Ffirst =A[3,1]
	outreg2 idv using "`path1'\RR_table003.txt" , ///
		append bdec(3) rdec(3) aster nocons nolabel ctitle("IV: Africa") ///
		addstat("1st stage F-stat", `Ffirst',"Partial R2",`R2first')
		
		
	ivreg2 pwt_ln_rgdpwok (idv = distM_UK) if cont==4, robust ffirst
	matrix A=e(first)
	local R2first=A[2,1]
	local Ffirst =A[3,1]
	outreg2 idv using "`path1'\RR_table003.txt" , ///
		append bdec(3) rdec(3) aster nocons nolabel ctitle("IV: America") ///
		addstat("1st stage F-stat", `Ffirst',"Partial R2",`R2first')
		
	
	xi: ivreg2 pwt_ln_rgdpwok (idv = distM_UK) i.cont if cont==1 | cont==2 | cont==3, robust ffirst
	matrix A=e(first)
	local R2first=A[2,1]
	local Ffirst =A[3,1]
	outreg2 idv using "`path1'\RR_table003.txt" , ///
		append bdec(3) rdec(3) aster nocons nolabel ctitle("IV: Africa + Asia + Europe") ///
		addstat("1st stage F-stat", `Ffirst',"Partial R2",`R2first')
		
		
		
	xi: ivreg2 pwt_ln_rgdpwok (idv = distM_UK) i.cont if cont==1 | cont==3, robust ffirst
	matrix A=e(first)
	local R2first=A[2,1]
	local Ffirst =A[3,1]
	outreg2 idv using "`path1'\RR_table003.txt" , ///
		append bdec(3) rdec(3) aster nocons nolabel ctitle("IV: Africa + Asia") ///
		addstat("1st stage F-stat", `Ffirst',"Partial R2",`R2first')
		
		
	xi: ivreg2 pwt_ln_rgdpwok (idv = distM_UK) i.cont if oecd==1, robust ffirst
	matrix A=e(first)
	local R2first=A[2,1]
	local Ffirst =A[3,1]
	outreg2 idv using "`path1'\RR_table003.txt" , ///
		append bdec(3) rdec(3) aster nocons nolabel ctitle("IV: OECD") ///
		addstat("1st stage F-stat", `Ffirst',"Partial R2",`R2first')
		
		
	xi: ivreg2 pwt_ln_rgdpwok (idv = distM_UK) i.cont if oecd==0, robust ffirst
	matrix A=e(first)
	local R2first=A[2,1]
	local Ffirst =A[3,1]
	di "`R2first'" "    " "`Ffirst'"
	outreg2 idv using "`path1'\RR_table003.txt" , ///
		append bdec(3) rdec(3) aster nocons nolabel ctitle("IV: non-OECD") ///
		addstat("1st stage F-stat", `Ffirst',"Partial R2",`R2first')

	
